package com.fei.BYSJ.service.impl;

import com.fei.BYSJ.dao.OrderMapper;
import com.fei.BYSJ.entity.Order;
import com.fei.BYSJ.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;


    @Override
    public int countOrderByPeoele(int userId) {
        return orderMapper.countOrderByPeoele(userId);
    }

    @Override
    public int releaseOrder(Order order) {
        return orderMapper.insert(order);
    }

    @Override
    public List<Order> findAllUnFinishOrder(int userId) {
        return orderMapper.selectAllUnFinishOrder(userId);
    }


    @Override
    public List<Order> findAll(int userId) {
        return orderMapper.selectByUserID(userId);
    }

    @Override
    public List<Order> findAcceptOrders(int userId) {
        return orderMapper.selectAcceptOrdersByUserID(userId);
    }

    @Override
    public List<Order> findFinishOrders(int userId) {
        return orderMapper.selectFinishOrdersByUserID(userId);
    }

    @Override
    public List<Order> findUnAcceptOrder() {
        return orderMapper.selectAllUnAcceptOrder();
    }

    @Override
    public List<Order> releaseOrderlists(Integer userid) {
        return orderMapper.selectReleaseOrderlists(userid);
    }

    @Override
    public Order findOrderById(int id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateOrder(Order o) {
        return orderMapper.updateByPrimaryKeySelective(o);
    }

    @Override
    public int cancelOrderById(int id) {
        return orderMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Order> findAllOrders(Map<String,Object> params) {
        return orderMapper.selectAllOrder(params);
    }

    @Override
    public List<Order> findAllComplainOrder(Integer userid) {
        return orderMapper.selectALLComplainOrder(userid);
    }

    @Override
    public List<Order> totalfindAllOrders(Map<String, Object> params) {
        return orderMapper.totalselectAllOrder(params);
    }

    @Override
    public int countOrderByDay(Date time) {
        return orderMapper.countOrderByDay(time);
    }

    @Override
    public Order findOrderByOrderNum(int parseInt) {
        return orderMapper.selectByOrderNum(parseInt);
    }
}
